import request from '@/utils/request'

// 列表
export function getAddonsList(page, size, search, type = 0) {
  return request({
    url: '/addons/index',
    method: 'post',
    data: { page, size, search, type }
  })
}

// 获取详情
export function getAddon(id) {
  return request({
    url: '/addons/show',
    method: 'post',
    data: { id }
  })
}

// 获取表单
export function getAddonForm(id) {
  return request({
    url: '/addons/form',
    method: 'post',
    data: { id }
  })
}

export function getAddonConfigForm(id) {
  return request({
    url: '/addons/getAddonConfigForm',
    method: 'post',
    data: { id }
  })
}

// 停用/开启
export function changeAddonStatus(id) {
  return request({
    url: '/addons/status',
    method: 'post',
    data: { id }
  })
}

// 安装
export function addonInstall(name) {
  return request({
    url: '/addons/install',
    method: 'post',
    data: { name }
  })
}

// 卸载
export function addonUnInstall(name) {
  return request({
    url: '/addons/uninstall',
    method: 'post',
    data: { name }
  })
}

// 更新
export function addonUpgrade(name) {
  return request({
    url: '/addons/upgrade',
    method: 'post',
    data: { name }
  })
}

export function checkUpgrade() {
  return request({
    url: '/addons/checkUpgrade',
    method: 'post'
  })
}
